{# ids must be unique doc-wide #}
{% set id = apos.util.generateId() %}
{% set widget = data.widget %}
{% set prependIfPrefix = apos.modules['@apostrophecms/form'].prependIfPrefix %}
<div data-apos-form-boolean class="apos-form-input-wrapper">
  <label for="{{ id }}"
    class="apos-form-label {{ prependIfPrefix('_label') }}"
  >
    {{ widget.fieldLabel}}
    {% if widget.required %} {{ __t("(Required)") }}{% endif %}
    <span
      class="apos-form-label-message {{ prependIfPrefix('__label-message') }}"
      data-apos-input-message="{{ widget.fieldName}}" hidden
    ></span>
  </label>
  <input type="checkbox" id="{{ id }}"
    class="apos-form-input {{ prependIfPrefix('__input') }}"
    name="{{ widget.fieldName}}" value="true"
    {% if widget.checked %}checked{% endif %}
    {% if widget.required %}required{% endif %}
  >
</div>
